import type {configInterFace} from "./type/index"
import axios from "axios"
import {getToken} from "@/utils/storage";
import { config } from "process";

const request =(configInterface)=>{
    const instance = axios.create({
        baseURL:"./",
        timeout:100000,
    })
    if(!config.headers){
        config.headers={
            "Content-Type":"application/json"
        }
    }
let Token = getToKen()
if(Token){
    config.headers={
        ...config.headers,
        'X-CSRF-TOKEN':`VueCms-xg${Token}`,
        'Authorization':`Bearer vuecms.cn`,
    }
}
instance.interceptors.request.use(config=>{
    return config
},err=>{
    console.log("请求拦截的报错信息",err);
})

instance.interceptors.response.use(val=>{
    return val;
}, err=>{
    console.log("响应拦截的报错信息",err);

})
return instance(config)
}
export{request}